<template>
  <el-dialog v-dialogDrag
             :title="'执行器详情 ['+this.agentForm.id + ']'"
             :close-on-click-modal="true"
             append-to-body
             :visible.sync="secondVisible" style="z-index: 32000;">
    <div style="overflow: auto; padding-right: 10px;">

    <el-form :model="agentForm" :rules="dataRule" ref="agentForm"
             class="rdonly" label-width="140px">
      <!--<el-row>
        <el-col :span="12">
          <el-form-item label="主键" prop="id">
            <el-input v-model="agentForm.id" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="任务执行日志ID" prop="taskExecLogId">
            <el-input v-model="agentForm.taskExecLogId" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>-->
      <el-row>
        <el-col :span="12">
          <el-form-item label="作业执行日志ID" prop="jobExecLogId">
            <el-input v-model="agentForm.jobExecLogId" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="任务触发时间戳" prop="taskTriggerTime">
            <el-input v-model="agentForm.taskTriggerTime" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <!--<el-col :span="12">
          <el-form-item label="异常错误累计次数" prop="execErrorNum">
            <el-input v-model="agentForm.execErrorNum" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>-->
        <el-col :span="12">
          <el-form-item label="代理实例IP" prop="agentIpv4">
            <el-input v-model="agentForm.agentIpv4" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="执行日期" prop="execDate">
            <el-input v-model="agentForm.execDate" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="应用模式" prop="appMode">
            <el-input v-model="agentForm.appMode" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="应用名称" prop="appJarName">
            <el-input v-model="agentForm.appJarName" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="运行模式" prop="appRunMode">
            <el-input v-model="agentForm.appRunMode" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="执行启动命令" prop="execStartupCmd">
            <el-input type="textarea" :autosize="{ minRows: 1, maxRows: 8}"
                      v-model="agentForm.execStartupCmd" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="执行状态" prop="execStatus">
            <el-input v-model="agentForm.execStatus" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>

      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="执行结果" prop="execResult">
            <el-input type="textarea" :autosize="{ minRows: 1, maxRows: 8}"
                      v-model="agentForm.execResult" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="启动时间" prop="startupTime">
            <el-input v-model="agentForm.startupTime" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="结束时间" prop="endTime">
            <el-input v-model="agentForm.endTime" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>

        <el-col :span="12">
          <el-form-item label="创建时间" prop="createTime">
            <el-input v-model="agentForm.createTime" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="更新时间戳" prop="updateTime">
            <el-input v-model="agentForm.updateTime" class="rdonly" :readonly="true"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    </div>

    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="secondVisible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data() {
      return {
        rowData: {},
        secondVisible: false,
        dataRule: {},
        agentForm: {},
      }
    },
    methods: {
      init(id, data) {
        this.agentForm.id = id || ''
        this.secondVisible = true
        this.rowData = data
        this.$nextTick(() => {
          this.$refs['agentForm'].resetFields();
        })
        this.queryAgent();
      },
      queryAgent(){
        let obj = {
          'id' : this.rowData.id,
          'jobExecLogId': this.rowData.jobExecLogId,
          'taskTriggerTime': this.rowData.taskTriggerTime
        }
        //obj = Object.assign(obj, this.searchForm)
        this.getTableList('/api/agent/exec/log/detail', obj, (data) => {
          this.agentForm = []
          this.dataListLoading = false
          if (data.code == '000000') {
            this.agentForm = data
          }
        })
      },

    }
  }
</script>
